<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>抽奖界面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .container {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        button {
            background: #007BFF;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background: #0056b3;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>抽奖系统</h1>
    <input type="number" id="num" placeholder="输入抽奖人数" min="1" style="padding: 10px;">
    <button onclick="randomDraw()">开始抽奖</button>
    <p id="result"></p>
</div>

<script>
    function randomDraw() {
        var num = document.getElementById('num').value;
        fetch('/random/paynum?num=' + num)
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    document.getElementById('result').innerText = '抽到的员工有：' + data.data.persons.join(', ');
                } else {
                    document.getElementById('result').innerText = data.message;
                }
            })
            .catch(error => {
                console.error('抽奖失败:', error);
                document.getElementById('result').innerText = '请求失败，请稍后再试';
            });
    }
</script>
</body>
</html>
